﻿/*
 * adc_uart_interrupt.c
 *
 * Created: 28.02.2013 22:38:11
 *  Author: Øyvind
 */ 


#include <avr/io.h>
#include <avr/interrupt.h>
#include "adc.h"
#include "usart.h"
#include "timer.h"

int main(void){
	sei();
	usart_init();
	timer_init();
	char welcome[] = "Hello thar! Program starting...\n";
	send_str(welcome);
	while(1);
    
}

ISR(ADC_vect) {
	uint16_t adc_value = ADC;
	//Process the information.
	char var_str[16];
	itoa(adc_value, var_str, 10);
	
	//Send it via uart.
	send_str(var_str);
	adc_off();
}

ISR(TIMER1_COMPA_vect){
	adc_init();
	adc_start();
}